package it.traveldream.utils;


public class DefaultValidator implements Validator {

	public final static String emailPattern = "[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?";
	public final static String passwdPattern = "[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+";
	public final static String usernamePattern = "[a-zA-Z0-9_-]+";
	
	@Override
	public boolean validateCredentials(String email, String password) {
		if (email.matches(emailPattern) && password.matches(passwdPattern))
			return true;
		return false;
	}
	
	@Override
	public boolean validateCredentials(String username, String email, String password) {
		if (email.matches(emailPattern) && 
				password.matches(passwdPattern) && username.matches(usernamePattern))
			return true;
		return false;
	}

}
